package com.htfg.cardActivate.user.controller;

import com.aliyuncs.exceptions.ClientException;
import com.htfg.cardActivate.core.ResultData;
import com.htfg.cardActivate.user.entity.BankPerson;
import com.htfg.cardActivate.user.entity.User;
import com.htfg.cardActivate.user.service.UserService;
import io.swagger.annotations.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther: 王晨缘
 * @Date: 2018/10/24 0024 16:55
 * @Description:
 */
@Api(value = "用户信息")
@Controller
@RequestMapping("/user")
public class UserController {
    private final Logger logger = Logger.getLogger(UserController.class);
    @Autowired
    private UserService userService;


    @ApiOperation(value="用户手机号验证成功调用接口", notes="注册用户信息",consumes ="application/x-www-form-urlencoded" )
    @ApiImplicitParams({
            @ApiImplicitParam(name="username", value="用户姓名", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="mobile", value="用户手机号", required=true, dataType="String",paramType = "query")
    })
    @RequestMapping(value="/registerBankPerson", method= RequestMethod.POST)
    @ResponseBody
    public ResultData registerBankPerson(String username,String mobile) {
       return userService.registerBankPerson(username,mobile);
    }

    @ApiOperation(value="发送手机验证码接口", notes="发送手机验证码",consumes ="application/x-www-form-urlencoded" )
    @ApiImplicitParams({
            @ApiImplicitParam(name="mobile", value="手机号", required=true, dataType="String",paramType = "query")
    })
    @RequestMapping(value = "/sendMobileCode",method= RequestMethod.POST)
    @ResponseBody
    public ResultData sendMobile(String mobile) throws ClientException {
        return userService.sendMobile(mobile);
    }
    @ApiOperation(value="银行人员注册3", notes="银行人员注册3",consumes ="application/x-www-form-urlencoded" )
    @ApiImplicitParams({
            @ApiImplicitParam(name="uid", value="用户id", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="bankName", value="银行名称", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="province", value="省", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="city", value="市", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="workNumber", value="工号", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="file", value="图片", required=true, dataType="file",paramType = "form"),
            @ApiImplicitParam(name="lon", value="经度", required=true, dataType="double",paramType = "query"),
            @ApiImplicitParam(name="lat", value="维度", required=true, dataType="double",paramType = "query"),
    })
    @RequestMapping(value = "/registerBankPersonDetail",method= RequestMethod.POST)
    @ResponseBody
    public ResultData<BankPerson> registerBankPersonDetail(String uid, String bankName, String province,
                                                           String city, String workNumber, MultipartFile file,
                                                           double lon, double lat) {
        return userService.registerBankPersonDetail(uid, bankName, province, city, workNumber, file,lon,lat);
    }

    @ApiOperation(value="客户注册", notes="客户注册")
    @RequestMapping(value = "/registerUser",method= RequestMethod.POST)
    @ResponseBody
    public ResultData<User> registerUser(@RequestBody @ApiParam(name="user",value="客户对象",required=true)User user) {
        return userService.registerUser(user);
    }

    @ApiOperation(value="附近业务人员", notes="附近业务人员")
    @ApiImplicitParams({
            @ApiImplicitParam(name="uid", value="用户id", required=true, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="bankName", value="银行名称", required=false, dataType="String",paramType = "query"),
            @ApiImplicitParam(name="lon", value="经度", required=false, dataType="double",paramType = "query"),
            @ApiImplicitParam(name="lat", value="维度", required=false, dataType="double",paramType = "query"),
            @ApiImplicitParam(name="pageIndex", value="第几页", required=false, dataType="int",paramType = "query"),
            @ApiImplicitParam(name="pageSize", value="一页几行", required=false, dataType="int",paramType = "query"),
    })
    @RequestMapping(value = "/nearbyBusinessPeople",method= RequestMethod.POST)
    @ResponseBody
    public ResultData<User> nearbyBusinessPeople(String uid, String bankName, Double lon, Double lat,
                                                 @RequestParam(name = "pageIndex", defaultValue = "1") Integer pageIndex,
                                                 @RequestParam(name = "pageSize", defaultValue = "5")Integer pageSize) {
        return userService.nearbyBusinessPeople(uid, bankName, lon, lat,pageIndex,pageSize);
    }

}
